combobox
Otázka od: prgx@email.cz
28. 6. 2004 22:19
Ahoj. Poradte mi vhodnou komponentu - combobox, ktera umi (podobne jako ms
access) zobrazovat v rozbalenem seznamu dva i vice sloupcu (napr. id,nazev...).
Diky, prgx (delphi 5 e)
Odpovedá: Petr Vones
15. 10. 2002 17:23
From: "LUKES Václav" <lukes@ans.cz>
> Na formu mam ComboBox, jehoz Items plnim v cyklu daty z tabulky ABC sloupcy
> PRIJMENI, JMENO a CISLO. To je OK a funguje to, jak ma.
> Ja bych ale chtel zobrazit JEN PRIJMENI a JMENO s tim, ze CISLO pouziju
> jinde.
Ty jednotlive polozky si v textove podobe oddel nejakym oddelovacem, nastav
u toho comboboxu Style na csOwnerDrawFixed a vykresluj polozky tak jak
potrebujes v udalosti OnDrawItem.
Petr Vones
Odpovedá: Roman
15. 10. 2002 17:47
>Ahoj,
>
>mam D6 Ent. a Win 2000 a rad bych vas poprosil o radu.
>
>Na formu mam ComboBox, jehoz Items plnim v cyklu daty z tabulky ABC sloupcy
PRIJMENI, JMENO a CISLO.
>To je OK a funguje to, jak ma.
>Ja bych ale chtel zobrazit JEN PRIJMENI a JMENO s tim, ze CISLO pouziju
jinde.
No tak do Items vkladej jen Prijmeni a Jmeno
(ComboBox.Items.Add(FieldByName('Prijmeni').asString+'
'+FieldByName('Jmeno').asString)
a to Cislo pouzij jinde
A kdybys nahodou jenom nechtel zobrazovat to Cislo u jednotlivych polozek,
tak ho bud ukladej do Items.Objects, nebo mej bokem nejaky zvlastni TList,
anebo pouzij treba ComboBox z RX, ten ma navic property Values.
Roman
==============================
http://kouzelne.misto.cz
Odpovedá: Lubos Urban
16. 10. 2002 6:59
Pokial je to cislo co si potrebujes odlozit ku kazdej polozke integer tak ho
mozes dat do vlastnosti object kazdej polozky
for i:= 0 to 10 do
Combo.Items.Objects[i]:= TObject(i);
a ked ho potrebujes nacitat tak len spravis
x:= Integer(Combo.Items.Objects[i])
jediny problem je v tom, ze ak do vlastnosti objects nic neulozis tak je tam
defaultne NIL a ten ked pretypujes na integer tak dostanes 0.
Ale inak je to v pohode
----- Original Message -----
From: "LUKES Václav" <lukes@ans.cz>
To: <delphi-l@clexpert.cz>
Sent: Tuesday, October 15, 2002 3:23 PM
Subject: ComboBox
Ahoj,
mam D6 Ent. a Win 2000 a rad bych vas poprosil o radu.
Na formu mam ComboBox, jehoz Items plnim v cyklu daty z tabulky ABC sloupcy
PRIJMENI, JMENO a CISLO.
To je OK a funguje to, jak ma.
Ja bych ale chtel zobrazit JEN PRIJMENI a JMENO s tim, ze CISLO pouziju
jinde.
Diky
Vasek
Odpovedá: LUKES Václav
16. 10. 2002 8:34
Dekuji Petrovi za radu, ale stejne se mi nedari...
Pokud udelam toto, dostanu data z tabulky do ComboBoxu:
begin
with Query1 do
begin
Active := false;
SQL.Clear;
SQL.Add('select prijmeni, jmeno, cislo from tabulka');
try
Open;
except
end;
ComboBox1.Items.Clear;
for i := 0 to RecordCount-1 do
begin
ComboBox1.Items.Add(Query1['prijmeni']+' '+Query1['jmeno']);
Next;
end;
end;
end;
Ja ale potrebuji pracovat v nasledujicim Editu s hodnotou ze sloupce CISLO,
ktera se vybere kliknutim na patricnem prijmeni v ComboBoxu...
V.
-----Original Message-----
From: Petr Vones [mailto:pvones@mbox.vol.cz]
Sent: Tuesday, October 15, 2002 3:36 PM
To: delphi-l@clexpert.cz
Subject: Re: ComboBox
From: "LUKES Václav" <lukes@ans.cz>
> Na formu mam ComboBox, jehoz Items plnim v cyklu daty z tabulky ABC sloupcy
> PRIJMENI, JMENO a CISLO. To je OK a funguje to, jak ma.
> Ja bych ale chtel zobrazit JEN PRIJMENI a JMENO s tim, ze CISLO pouziju
> jinde.
Ty jednotlive polozky si v textove podobe oddel nejakym oddelovacem, nastav
u toho comboboxu Style na csOwnerDrawFixed a vykresluj polozky tak jak
potrebujes v udalosti OnDrawItem.
Petr Vones
Odpovedá: Ales Vasicek
16. 10. 2002 9:52
Ahoj,
pouzij ComboBox1.Items.AddObject(Query1['prijmeni']+' '+Query1['jmeno'],
Pointer(Query1['cislo']));
a cislo dostanes
X := Integer(ComboBox1.Items.Objects[ComboBox1.ItemIndex]);
Ales.
> -----Original Message-----
> From: LUKES Václav [mailto:lukes@ans.cz]
>
> Ja ale potrebuji pracovat v nasledujicim Editu s hodnotou ze
> sloupce CISLO, ktera se vybere kliknutim na patricnem
> prijmeni v ComboBoxu...
Odpovedá: Marek Spisak
29. 6. 2004 7:59
prgx@email.cz wrote:
>Ahoj. Poradte mi vhodnou komponentu - combobox, ktera umi (podobne jako ms
access) zobrazovat v rozbalenem seznamu dva i vice sloupcu (napr. id,nazev...).
Diky, prgx (delphi 5 e
>
napr.: TRxDBLookupCombo component z RX Lib
Marek
Description
Data aware combo box with look up.
The TRxDBLookupCombo visual interface component provides your end-users
with the ability to select a value for a field from a drop-down list of
values that is populated from a second lookup table.
If TRxDBLookupCombo is linked to a lookup field component, it
automatically reads the relationship between the field value and the
lookup values in the lookup dataset from the field component. The
relationship between field values and the corresponding values in the
lookup dataset can also be explicitly set using the properties of the
lookup combo box when the combo box is not linked toa lookup field
component.
This component provides the following:
? You can select any number of fields to be displayed in the
drop-down list.
==========================================================
? End-users can incrementally search through the lookup list by
directly typing into the combo control while the lookup list is
displayed. This is a great advantage when using lookup tables that
contain hundreds of even thousands of records.
? You can perform a lookup on a Query or QBE result. It even
incrementally searches on the query result.
? The component does not have to be bound, or assigned, to a
table's
field (DataField and DataSource properties) which gives you greater
flexibility in using this LookupCombo for general tasks where a source
table is not involved.
If DataSource and DataField properties is set, when a user selects a
list item, the corresponding field value is changed in the underlying
dataset.
If IgnoreCase property is True (default), the incrementally search
through the lookup list is processed without regard to case in the
dataset's
data.
If IndexSwitch property is True (default) and TTable component is linked
to the LookupSource, the incrementally search will use available indices
of lookup table.
The DisplayEmpty property allows you specify the text value to display
when no item is selected from the lookup list. If DisplayEmpty set to
the non-empty string, this value will be show in the drop-down list
additionaly to the lookup items.
Use DropDownAlign property to specify how the drop-down list is aligned
relative to its edit box.
Use an OnGetImage event to specify graphical picture to display in each
item of lookup list accordingly to the contents of lookup source.
Write an OnChange event handler to take specific action immediately
after the user selects an item from the list and the Value property changed.